home *** CD-ROM | disk | FTP | other *** search
/ Advanced Placement Companion: Precalculus / Advanced Placement Companion: Precalculus.iso / pc / M_DIR / 12-01005.DIR / 00013.ls < prev    next >
Encoding:
Text File  |  1998-04-15  |  6.6 KB  |  233 lines

  1. on setUp buttonSprite, spec, graphicSprite, Destination
  2.   global actions, buttons
  3.   if buttonSprite = #NEW then
  4.     initSetUp()
  5.     exit
  6.   end if
  7.   if buttonSprite = #BLINK then
  8.     add(actions, [#BLINK, spec, graphicSprite])
  9.     exit
  10.   end if
  11.   if ilk(buttonSprite) <> #integer then
  12.     setUpHelp(buttonSprite)
  13.     exit
  14.   end if
  15.   setCursor(spec, buttonSprite)
  16.   if ilk(graphicSprite) = #integer then
  17.     set the visible of sprite graphicSprite to 0
  18.   end if
  19.   add(buttons, [buttonSprite, spec, graphicSprite, Destination])
  20. end
  21.  
  22. on initSetUp
  23.   global mouseState, buttons, actions, lastBlink
  24.   set buttons to []
  25.   set actions to []
  26.   set lastBlink to 0
  27.   set mouseState to #UP
  28. end
  29.  
  30. on FrameLoop
  31.   global aState, dState, buttons
  32.   repeat with def in buttons
  33.     set buttonSprite to getAt(def, 1)
  34.     set spec to getAt(def, 2)
  35.     set graphicSprite to getAt(def, 3)
  36.     set Destination to getAt(def, 4)
  37.     if rollOver(buttonSprite) then
  38.       set mState to getMouseState()
  39.       if spec = #A then
  40.         if mState = #down then
  41.           doClick()
  42.           if aState = 1 then
  43.             set the visible of sprite graphicSprite to 0
  44.           end if
  45.         else
  46.           if mState = #UP then
  47.             if aState = 0 then
  48.               set aState to 1
  49.               set the visible of sprite graphicSprite to 1
  50.             else
  51.               set aState to 0
  52.             end if
  53.           else
  54.             set the visible of sprite graphicSprite to 1
  55.           end if
  56.         end if
  57.       else
  58.         if spec = #B then
  59.         else
  60.           if spec = #C then
  61.             if the visible of sprite Destination = 0 then
  62.               set the visible of sprite graphicSprite to 1
  63.             end if
  64.           else
  65.             if spec = #D then
  66.               if mState = #down then
  67.                 doClick()
  68.                 set the visible of sprite graphicSprite to 1
  69.               else
  70.                 if mState = #UP then
  71.                   set the visible of sprite graphicSprite to 0
  72.                   GoTo(Destination, buttonSprite, graphicSprite)
  73.                 end if
  74.               end if
  75.             else
  76.               if spec = #E then
  77.                 if mState = #down then
  78.                   doClick()
  79.                   if ilk(graphicSprite) = #integer then
  80.                     set the visible of sprite graphicSprite to 1
  81.                   end if
  82.                 end if
  83.                 if mState = #UP then
  84.                   setCursor(spec, buttonSprite)
  85.                   go(Destination)
  86.                   exit
  87.                 end if
  88.               end if
  89.             end if
  90.           end if
  91.         end if
  92.       end if
  93.       next repeat
  94.     end if
  95.     if (spec = #A) and (aState <> 1) then
  96.       set the visible of sprite graphicSprite to 0
  97.     end if
  98.     if spec = #C then
  99.       set the visible of sprite graphicSprite to 0
  100.     end if
  101.   end repeat
  102.   doActions()
  103. end
  104.  
  105. on doActions
  106.   global actions, lastBlink
  107.   set ptr to 1
  108.   repeat while ptr <= count(actions)
  109.     set action to getAt(actions, ptr)
  110.     set actionName to getAt(action, 1)
  111.     set n to getAt(action, 2)
  112.     set graphicSprite to getAt(action, 3)
  113.     if actionName = #BLINK then
  114.       if (the timer > lastBlink) and ((n >= 0) or (n = #FOREVER)) then
  115.         if the visible of sprite graphicSprite = 1 then
  116.           set the visible of sprite graphicSprite to 0
  117.         else
  118.           set the visible of sprite graphicSprite to 1
  119.           if n <> #FOREVER then
  120.             set n to n - 1
  121.             setAt(action, 2, n)
  122.             setAt(actions, ptr, action)
  123.             if n < 0 then
  124.               set the visible of sprite graphicSprite to 0
  125.             end if
  126.           end if
  127.         end if
  128.         set lastBlink to the timer + 20
  129.       end if
  130.     end if
  131.     set ptr to ptr + 1
  132.   end repeat
  133. end
  134.  
  135. on setCursor spec, sNum
  136.   if (spec = #A) or (spec = #D) or (spec = #E) then
  137.     set the cursor of sprite sNum to [cast "Hand Cursor", cast "hand cursor alpha"]
  138.   else
  139.     if spec = #B then
  140.       alert("custom programming requested - ask mark")
  141.     else
  142.       if spec = #C then
  143.       end if
  144.     end if
  145.   end if
  146. end
  147.  
  148. on getMouseState
  149.   global mouseState
  150.   if the mouseDown then
  151.     if mouseState <> #down then
  152.       set mouseState to #down
  153.       return mouseState
  154.     end if
  155.   end if
  156.   if the mouseUp then
  157.     if mouseState <> #UP then
  158.       set mouseState to #UP
  159.       return mouseState
  160.     end if
  161.   end if
  162.   return #NONE
  163. end
  164.  
  165. on GoTo Destination, buttonSprite, graphicSprite
  166.   set the cursor of sprite buttonSprite to -1
  167.   go(Destination)
  168. end
  169.  
  170. on doClick
  171.   puppetSound("click")
  172.   updateStage()
  173. end
  174.  
  175. on setUpHelp spec
  176.   if (spec = #A) or (ilk(spec) = #void) then
  177.     put "Spec #A requires a graphicSprite but no frame destination"
  178.     put "ie: set(11, #A, 7, VOID)"
  179.     put "    11 is the sprite number of the button"
  180.     put "    #A is the navigation specification"
  181.     put "    7 is the graphic which turns on or off."
  182.     put "    The frame does not change with Spec #A"
  183.     put RETURN
  184.   end if
  185.   if (spec = #B) or (ilk(spec) = #void) then
  186.     put "Spec #B has not been implemented yet. Ask Mark to get busy!"
  187.     put RETURN
  188.   end if
  189.   if (spec = #C) or (ilk(spec) = #void) then
  190.     put "Spec #C requires a graphicSprite but no frame destination"
  191.     put "ie: set(11, #C, 7, VOID)"
  192.     put "    11 is the sprite number of the button"
  193.     put "    #A is the navigation specification"
  194.     put "    7 is the graphic which turns on or off"
  195.     put "    The frame does not change with Spec #C"
  196.     put RETURN
  197.   end if
  198.   if (spec = #D) or (ilk(spec) = #void) then
  199.     put "Spec #D requires a graphicSprite but no frame destination"
  200.     put "ie: set(11, #D, 7, VOID)"
  201.     put "    11 is the sprite number of the button"
  202.     put "    #D is the navigation specification"
  203.     put "    7 is the graphic which turns on or off"
  204.     put "    The frame does not change with Spec #D"
  205.     put RETURN
  206.   end if
  207.   if (spec = #E) or (ilk(spec) = #void) then
  208.     put "Spec #E requires no graphicSprite but requires a frame destination"
  209.     put "ie: set(11, #E, VOID," & QUOTE & "answers" & QUOTE & ")"
  210.     put "    11 is the sprite number of the button"
  211.     put "    #E is the navigation specification"
  212.     put "    No graphic turns on or off"
  213.     put "    The frame jumps to 'answers' when the button is clicked"
  214.     put RETURN
  215.   end if
  216. end
  217.  
  218. on palettes
  219.   global palettes
  220.   put "palette check:"
  221.   set palettes to 0
  222.   repeat with i = 1 to the number of castMembers
  223.     if the castType of cast i = #bitmap then
  224.       if the depth of cast i > 1 then
  225.         if the palette of cast i <> 1 then
  226.           put "cast:" & i && "(" & the name of cast i & "&)" && "bitdepth:" & the depth of cast i && "palete:" & the palette of cast i
  227.         end if
  228.       end if
  229.     end if
  230.   end repeat
  231.   put "done"
  232. end
  233.